package com.mymoney.constants;

/**
 * This class contains paths of the different server side services that we use. Singleton.
 *
 * @author georgi.tsankov
 */
public class RequestPaths {
	
	private final String HOST_PATH = Constants.host + Constants.contexPath;
    
    private final String REGISTER_DEVICE_PATH = "/devices/device";
    
    private final String MODIFY_DEVICE_PATH = "/devices/device/%s";
    
    private final String GET_DEVICE_PATH = "/devices/device/%s";
    
    private final String GET_PLANNED_ITEMS_PATH = "/items/planned";
    
    private final String GET_BOUGHT_ITEMS_PATH = "/items/bought";
    
    private final String MODIFY_ITEM_PATH = "/items/item/%s";
    
    private final String ADD_ITEM_PATH = "/items/item";

    private static RequestPaths instance = new RequestPaths();

    public static RequestPaths getInstance() {
        if (instance == null) {
            instance = new RequestPaths();
        }
        return instance;
    }
    
    public String createRegisterDeviceRequestPath(String platform) {
        return getHostPath() + String.format(REGISTER_DEVICE_PATH,platform);
    }

    public String createModifyDeviceRequestPath(String deviceUid) {
        return getHostPath() + String.format(MODIFY_DEVICE_PATH, deviceUid);
    }
    
    public String createGetDeviceRequestPath(String deviceUid) {
        return getHostPath() + String.format(GET_DEVICE_PATH, deviceUid);
    }

	public String getHostPath() {
		return HOST_PATH;
	}
	
    public String createGetPlannedItemsPath() {
        return getHostPath() + String.format(GET_PLANNED_ITEMS_PATH);
    }
    
    public String createGetBoughtItemsPath() {
        return getHostPath() + String.format(GET_BOUGHT_ITEMS_PATH);
    }

	public String createModifyItemPath(String code) {
		return getHostPath() + String.format(MODIFY_ITEM_PATH, code);
	}
	
	public String createAddItemPath() {
		return getHostPath() + String.format(ADD_ITEM_PATH);
	}
}
